﻿using MODEL;
using SysHelper;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Mvc;

namespace SysController.Amazon
{
    public class BaseController : Controller
    {
        [HttpGet]
        public ActionResult TemplateProperty()
        { 
            return View();
        }

        [HttpPost]
        public ActionResult TemplateProperty(TemplateProperty model)
        {
            AjaxMsgModel ajax = new AjaxMsgModel();
            if (!ModelState.IsValid)
            { 
                ajax.Statu = AjaxMsgStatuEnum.Failure.ToString();
                ajax.Msg = "数据有错误！请标准填写";
            }
            else
            {
                OperateContext.CurrentContext.BllSession.ITemplateProperty_BLL.ModifyIsNullADD(model, s => s.Template == model.Template && s.Property == model.Property, true);
                OperateContext.CurrentContext.BllSession.SaveChanges(typeof(TemplateProperty).Name);
                ajax.Statu = AjaxMsgStatuEnum.Success.ToString();
                ajax.Msg = "提交成功";
            }
            return Json(ajax, JsonRequestBehavior.AllowGet);
        }

        public ActionResult GetTemplateProperty()
        {

            return Json(OperateContext.CurrentContext.BllSession.ITemplateProperty_BLL.GetListByWhere(s => true, s => s.TemplatePropertyID, false), JsonRequestBehavior.AllowGet);
        }

    }
}
